package com.xindaoapp.henghua.protocol.model;

import org.json.JSONException;
import org.json.JSONObject;

import com.alibaba.fastjson.JSON;
import com.loopj.android.http.util.MoccaRequest;
import com.loopj.android.http.util.Response.ErrorListener;
import com.loopj.android.http.util.Response.Listener;
import com.xindaoapp.henghua.entry.UserInfo;
import com.xindaoapp.henghua.utils.MoccaPreferences;

public class LoginRequest extends MoccaRequest<UserInfo> {

	public LoginRequest(String url, Listener<UserInfo> listener, ErrorListener errorListener) {
		super(url, listener, errorListener);
	}

	@Override
	public UserInfo parseNetworkResponse(String response) {
		UserInfo info = null;
		try {
			info = JSON.parseObject(new JSONObject(response).getJSONObject("content").toString(),
					UserInfo.class);
			MoccaPreferences.UERERINFO.put(response);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return info;
	}

}
